package com.scvtc.controller.dictionary;

import com.scvtc.domain.ForeignKeyCache;
import com.scvtc.domain.ResResult;
import com.scvtc.service.dictionary.DictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Description: 数据字典
 * @Author: yiFei
 * @date: 2022/5/13 11:14
 */
@RestController
@Api(tags = "数据字典控制层")
@RequestMapping("dictionary")
public class DictionaryController {

    @Autowired
    private DictionaryService dictionaryService;

    @GetMapping("form")
    @ApiOperation("获取表单信息")
    public ResResult<Map<String, List<String>>> form() {
        return dictionaryService.form();
    }

    @GetMapping("/student/base")
    @ApiOperation("学生姓名提示")
    public ResResult<List<ForeignKeyCache>> studentBase(@RequestParam(value = "studentName", required = false) String studentName) {
        return dictionaryService.studentBase(studentName);
    }

    @GetMapping("/teacher/base")
    @ApiOperation("教师姓名提示")
    public ResResult<List<ForeignKeyCache>> teacherBase(@RequestParam(value = "teacherName", required = false) String teacherName) {
        return dictionaryService.teacherBase(teacherName);
    }
}
